package com.fary.beans;

import com.fary.core.MethodParameter;
import com.fary.core.SpringException;
import com.fary.core.convert.TypeDescriptor;

import java.lang.reflect.Field;

public interface TypeConverter {

    <T> T convertIfNecessary(Object value, Class<T> requiredType) throws SpringException;

    <T> T convertIfNecessary(Object value, Class<T> requiredType, MethodParameter methodParam) throws SpringException;

    <T> T convertIfNecessary(Object value, Class<T> requiredType, Field field) throws SpringException;

    default <T> T convertIfNecessary(Object value, Class<T> requiredType, TypeDescriptor typeDescriptor) throws SpringException {
        throw new UnsupportedOperationException("TypeDescriptor resolution not supported");
    }

}